import { InitModalMethod } from './defination';

/**
 * 设置表单属性
 * @param { Object } form 表单数据
 * @param { Object } workstep cached的ai工作流
 */
export const initModalData = (form = {}, workstep = {}) => {
	if (!form || !workstep || !workstep.do) {
		return;
	}

	form.aiProcessSpeech = workstep.answer[0]?.do?.data;
	// yes
	if (workstep.answer[0]?.after) {
		form.wordsYes = workstep.answer[0]?.do?.data; // 2
		form.nextStepYes = workstep.answer[0]?.after?.id;
	} else {
		form.nextStepYes = workstep.answer[0]?.do?.id;
	}
	// no
	if (workstep.answer[1]?.after) {
		form.wordsNo = workstep.answer[1]?.do?.data; // 4
		form.wordsNoVideo = workstep.answer[1]?.do?.video;
		form.nextStepNo = workstep.answer[1]?.after?.id;
	} else {
		form.nextStepNo = workstep.answer[1]?.do?.id;
	}
	// form.nextStepNo = workstep.answer[1]?.after?.id;
	// other
	form.wordsOther = workstep.errorRemind?.do?.data;
	form.otherTimesMax = workstep.errorRemind?.maximum;
	form.nextStepOther = workstep.errorRemind?.after?.id;

	// 预录制视频属性
	form.aiSpeakVideo = null;
	form.wordsYesVideo = null;
	form.wordsNoVideo = null;
	form.wordsOtherVideo = null;
	form.wordsEndVideo = null;
	form.wordsNoAnswerVideo = null;
	form.wordsEndNoAnswerVideo = null;
};
InitModalMethod['signContract'] = initModalData;
